﻿// ===============================================================================
// NumberRule.cs
// EOS Framework
// ===============================================================================
// Copyright (c) EOS Development Group. All rights reserved.
// ===============================================================================

namespace EOS.Framework.Rules
{
    /// <summary>
    /// Rule for simple numbers with letters. For example 123a, 34f. Use this for streetnumbers.
    /// </summary>
    public class NumberRule : RegexRule
    {        
        /// <summary>
        /// Initializes a new instance of the <see cref="NumberRule"/> class 
        /// with a description.
        /// </summary>
        /// <param name="brokenDescription">The description.</param>
        /// <exception cref="ArgumentNullException"><paramref name="brokenDescription"/> is
        /// null (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentException"><paramref name="brokenDescription"/> is a string
        /// of length 0 or contains only blanks.</exception>
        public NumberRule(string brokenDescription)
            : this(brokenDescription, false)
        { 
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="NumberRule"/> class    
        /// with a description and a flag, indicating, if the value can be empty.
        /// </summary>
        /// <param name="canBeEmpty">if set to <c>true</c> the value can be empty.</param>
        /// <param name="brokenDescription">The description.</param>
        /// <exception cref="ArgumentNullException"><paramref name="brokenDescription"/> is
        /// null (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentException"><paramref name="brokenDescription"/> is a string
        /// of length 0 or contains only blanks.</exception>
        public NumberRule(string brokenDescription, bool canBeEmpty)
            : base(brokenDescription,
            "^[1-9]{1}[0-9]*([,.]{1}[0-9]+)?$",
            canBeEmpty)
        { 
        }
    }
}